import CommentBox from "../client/commentBox";
import { api } from "@/lib/api";

async function HomeCenter({
  searchParams,
}: {
  searchParams?: { menu?: string };
}) {
  const menu = searchParams?.menu || "1";
  const apiUrl =
    menu === "1"
      ? "/api/comment"
      : menu === "2"
      ? "/api/relativeComment"
      : "/api/comment";
  const res = await fetch(await api(apiUrl), { next: { revalidate: 60 } });
  const commentList = await res.json();
  return (
    <>
      <CommentBox commentList={commentList} />
    </>
  );
}

export default HomeCenter;
